package com.whitedust.top10;

/**
 * @author A
 * @since 2025/11/2 12:56
 */

public class Top7 {
    public int maxSubArray(int[] nums) {
        int[] dp = new int[nums.length+10];
        dp[0]=nums[0];
        int res = dp[0];
        for(int i =1;i<nums.length;i++){
            dp[i] = Math.max(dp[i-1]+nums[i],nums[i]);
            res = Math.max(res,dp[i]);
        }
        return res;
    }
}
